{include file="public/header"/}
<style>
    .layui-col-xs3 .layui-form-radio, .layui-col-xs4 .layui-form-radio {
        width: 100%;
    }
</style>
<div class="layui-container">
    <div class="layui-main">
        <form class="layui-form" autocomplete="off">
            <div class="layui-form">
                <div class="layui-form-item">
                    <div class="zent-block-header block-header margin-bottom-5">
                        <div class="zent-block-header__title zent-block-header__title-ribbon">
                            <h3>出题数量</h3>
                        </div>
                    </div>
                    <div class="layui-input-block layui-col-space15 margin-left-0">
                        {foreach $getPracticeNum as $key => $v}
                        <div class="layui-col-xs3">
                            <input type="radio" name="practice_num" value="{$key}" lay-skin="none" {if $set.practiceNum == $key} checked {/if}>
                            <div lay-radio class="lay-skin-checkcard lay-check-dot" style="height: 46px;">
                                <div class="lay-skin-checkcard-detail text-align-center">
                                    <div class="lay-skin-checkcard-header layui-font-14">{$v}</div>
                                </div>
                            </div>
                        </div>
                        {/foreach}
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="zent-block-header block-header margin-bottom-5">
                        <div class="zent-block-header__title zent-block-header__title-ribbon">
                            <h3>抽题模式</h3>
                        </div>
                    </div>
                    <div class="layui-input-block layui-col-space15 margin-left-0">
                        {foreach $getPracticeType as $key => $v}
                        <div class="layui-col-xs4">
                            <input type="radio" name="practice_type" value="{$key}" lay-skin="none" {if $set.practicetype == $key} checked {/if}>
                            <div lay-radio class="lay-skin-checkcard lay-check-dot" style="height: 46px;">
                                <div class="lay-skin-checkcard-detail text-align-center">
                                    <div class="lay-skin-checkcard-header layui-font-14">{$v}</div>
                                </div>
                            </div>
                        </div>
                        {/foreach}
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="zent-block-header block-header margin-bottom-5">
                        <div class="zent-block-header__title zent-block-header__title-ribbon">
                            <h3>刷题模式</h3>
                        </div>
                    </div>
                    <div class="layui-input-block layui-col-space15 margin-left-0">
                        {foreach $getPracticeMode as $key => $v}
                        <div class="layui-col-xs4">
                            <input type="radio" name="practice_mode" value="{$key}" lay-skin="none" {if $set.practicemode == $key} checked {/if}>
                            <div lay-radio class="lay-skin-checkcard lay-check-dot" style="height: 46px;">
                                <div class="lay-skin-checkcard-detail text-align-center">
                                    <div class="lay-skin-checkcard-header layui-font-14">{$v}</div>
                                </div>
                            </div>
                        </div>
                        {/foreach}
                    </div>
                </div>
            </div>

            <div class="hr-line"></div>
            <div class="layui-form-item">
                <div class="layui-input-block text-align-center margin-left-0">
                    <button class="layui-btn layui-bg-success" id="saveBtn" lay-submit lay-filter="saveBtn">保存设置</button>
                    <a class="layui-btn layui-btn-primary" id="cancelBtn">取 消</a>
                </div>
            </div>
        </form>
    </div>
</div>

<script type="text/javascript">
    layui.use(['form','layer'], function(){
        var layer = layui.layer, form = layui.form, $=layui.jquery;
        
        $("#cancelBtn").on('click',function(){
            var index = parent.layer.getFrameIndex(window.name); //获取当前窗口的name
            parent.layer.close(index);//关闭窗口  
        });

        form.on('submit(saveBtn)', function(data){
            var loading = layer.msg('数据处理中..', {icon: 16,shade: 0.3,time: false});
            $.ajax({
                url:'/question/practice_set',
                type:'post',
                data:data.field,
                dataType:"JSON",
                headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') },
                success:function(res){
                    layer.close(loading);  //返回数据关闭loading
                    if(res.code == 0){
                        $("#saveBtn").removeClass("layui-bg-success").addClass("layui-btn-disabled");
                        $("#saveBtn").attr("disabled","true");
                        layer.msg(res.msg,{icon: 1,time:1500},function(){
                            var index= parent.layer.getFrameIndex(window.name);//获取当前层
                            parent.layer.close(index);//关闭当前层
                        });
                        
                    } else{
                        layer.msg(res.msg,{icon: 2});
                    }
                },
                error:function(e){
                    layer.msg('请求失败'+e.responseText,{icon: 2});
                },
                
            });
            return false;
        });

    });
    
</script>